package com.demo;

import java.util.Arrays;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        // 1. 准备测试数据
        List<UserAction> actions = Arrays.asList(
            new UserAction("User1", "商品A", "view", 3),
            new UserAction("User1", "商品A", "order", 1),
            new UserAction("User1", "商品B", "favorite", 1),
            new UserAction("User1", "商品D", "view", 2),
            new UserAction("User1", "商品D", "cart", 1),
            new UserAction("User2", "商品A", "favorite", 1),
            new UserAction("User2", "商品C", "order", 2),
            new UserAction("User3", "商品B", "cart", 1),
            new UserAction("User3", "商品C", "order", 1)
        );
        
        // 2. 构建推荐系统
        RecommenderSystem recommender = new RecommenderSystem();
        recommender.buildInterestMatrix(actions);
        recommender.calculateUserSimilarity();

        // 推荐用户
        String username = "User3";
        
        // 3. 生成推荐
        List<Recommendation> recommendations = recommender.recommendItems(username, 3);
        
        // 4. 输出结果
        System.out.printf("给%s的推荐商品：",username);
        recommendations.forEach(rec -> 
            System.out.printf("商品: %s, 推荐分数: %.2f%n", 
                rec.getItemId(), rec.getScore()));
    }
}